// WLock.h: interface for the WLock class.
//
//////////////////////////////////////////////////////////////////////

#ifndef SKYROAD__AUTO_LOCK_H__
#define SKYROAD__AUTO_LOCK_H__


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "basetype.h"

#ifndef _WIN32
#include <pthread.h>
#include <errno.h>
#endif

class skylock  
{
public:
    skylock();
    virtual ~skylock();
public:
    void unlock();
    void lock();
    bool trylock();
private:
#ifdef _WIN32
    mutable CRITICAL_SECTION m_Lock;
#else
    mutable pthread_mutex_t m_Lock;
#endif
    mutable int m_nCount;
};
class auto_lock  
{
public:
    auto_lock( skylock* pLock );
    virtual ~auto_lock();

private:
    skylock*  m_pLock;
};
#endif // !defined(AFX_WLOCK_H__215ADB87_70CF_4950_B1FB_04855FB7981B__INCLUDED_)
